/**
@file CCS811.h
@brief CCS811 air sensor macro and data struct
@author wangjia
@date 2017-1-8
*/
#ifndef _CCS811_H_
#define _CCS811_H_

#include "et_types.h"

#define CCS811_DEV_ADDR				(0x5A)	///< I2C_ADDR low:0x5A, high:0x5B

#define CCS811_ADDR_STATUS			(0x00)
#define CCS811_ADDR_MEAS_MODE		(0x01)
#define CCS811_ADDR_ALG_RESULT_DATA	(0x02)
#define CCS811_ADDR_RAW_DATA		(0x03)
#define CCS811_ADDR_ENV_DATA		(0x05)
#define CCS811_ADDR_NTC				(0x06)
#define CCS811_ADDR_THRESHOLDS		(0x10)
#define CCS811_ADDR_BASELINE		(0x11)
#define CCS811_ADDR_HW_ID			(0x20)
#define CCS811_ADDR_HW_VER			(0x21)
#define CCS811_ADDR_FW_BOOT_VER		(0x23)
#define CCS811_ADDR_FW_APP_VER		(0x24)
#define CCS811_ADDR_ERROR_ID		(0xE0)
#define CCS811_ADDR_SW_RESET		(0xFF)

/**
@brief STATUS register
*/
///@{
#define CCS811_STATUS_ERROR			(0x01)
#define CCS811_STATUS_DATA_READY	(0x08)
#define CCS811_STATUS_APP_VALID		(0x10)
#define CCS811_STATUS_FW_MODE		(0x80)
///@}

/**
@brief MEAS_MODE register
*/
///@{
#define CCS811_MEAS_MODE_THRESH		(0x04)
#define CCS811_MEAS_MODE_INTERRUPT	(0x08)
#define CCS811_MEAS_MODE_DRIVE_MODE	(0x70)
///@}

/**
@brief HW_ID value
*/
#define CCS811_HW_ID				(0x81)

/**
@brief ERROR_ID	register
*/
///@{
#define CCS811_ERROR_MSG_INVALID			(0x01)
#define CCS811_ERROR_READ_REG_INVALID		(0x02)
#define CCS811_ERROR_MEASMODE_INVALID		(0x04)
#define CCS811_ERROR_MAX_RESISTANCE			(0x08)
#define CCS811_ERROR_HEATER_FAULT			(0x10)
#define CCS811_ERROR_HEATER_SUPPLY			(0x20)
///@}

/**
@brief SW_RESER sequence
*/
///@{
#define CCS811_SW_RESET_SEQ0		(0x11)
#define CCS811_SW_RESET_SEQ1		(0xE5)
#define CCS811_SW_RESET_SEQ2		(0x72)
#define CCS811_SW_RESET_SEQ3		(0x8A)
///@}
#endif